Total mechanical energy is defined as the sum of the potential and kinetic energies of an object at any given time:
If all of the forces acting on an object are conservative or if the work done by the non-conservative forces is 0, then total mechanical energy is conserved. That is, if the object slows in velocity and loses some kinetic energy, there must be a corresponding increase in the potential energy. If the work done by non-conservative forces is not 0, then the change in energy must equal the amount of work done:
A ballistic pendulum is a device consisting of a stationary hanging wood block attached to a string. In the inelastic collision between a bullet and the block momentum is conserved but energy is not conserved.